<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        input {
            width: 200px;
            height: 40px;
        }

        body {
            text-align: center;
            background-color: rgba(255, 192, 203, 1);
        }

        #username {
            border-radius: 50px;
            text-align: center;
            border: none;
            outline: none;
        }

        #password {
            border-radius: 50px;
            text-align: center;
            border: none;
            /* 去掉外轮廓 */
            outline: none;
        }

        #in3 {
            border-radius: 50px;
            text-align: center;
            border: none;
            width: 70px;
            height: 20px;
            outline: none;
            background-color: yellow;
        }

        #h1 {
            font-size: 50px;
            color: #FFFF;
            margin-top: 200px;
        }
    </style>
</head>

<body>
    <h1 id="h1">欢迎注册</h1>
    <form action="">
        <input id="username" type="text" placeholder="请输入账号"><br>
        <br>
        <input id="password" type="password" placeholder="请输入密码"><br>
        <br>
        <button id="in3" type="button" onclick="zhuce()">注册</button>
        <a href="index.html">已注册，去登录</a>
    </form>

    <script>
        //函数：执行一系列的一段代码。
        function zhuce() {
            alert("注册成功")
            //步骤：1.提取输入框的账号，密码。
            var username = document.querySelector("#username").value;
            var password = document.querySelector("#password").value;

            //2.将账号，密码存储到本地缓存 localstorage 中。
            localStorage.setItem("username", username);//key-value
            localStorage.setItem("password", password);//key-value


            //3.自动跳转到登录页面（地址栏替换为登录页面，间接地实现跳转）
            location.href = "index.html";
        }
    </script>
</body>

</html>